<?php
namespace Topxia\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Topxia\Common\Paginator;
use Topxia\Common\ArrayToolkit;

class BaomingController extends BaseController 
{

    public function indexAction (Request $request)
    {
        $fields = $request->query->all();

        $conditions = array(
            'xingming'=>'',
            'zhunkaozheng'=>'',
            'shenfenzheng'=>'',
            'dianhua'=>'',
            'zhuankeyuanxiao'=>'',
            'zhuanye'=>'',
            'benkeyuanxiaozhuanye'=>'',
            'kaoshifenshu'=>null,
            'zhuanyefenshu'=>null,
            'banci'=>'',
            'ganyan'=>''
        );

        if(empty($fields)){
            $fields = array();
        }

        $conditions = array_merge($conditions, $fields);
        $paginator = new Paginator(
            $this->get('request'),
            $this->getBaomingService()->searchBaomingCount($conditions),
            20
        );

        $baominglist = $this->getBaomingService()->searchBaoming(
            $conditions,
            array('createdTime', 'DESC'),
            $paginator->getOffsetCount(),
            $paginator->getPerPageCount()
        );

        return $this->render('TopxiaAdminBundle:Kuke:baoming.html.twig', array(
            'baominglist' => $baominglist ,
            'paginator' => $paginator
        ));
    }
    
     

    protected function getBaomingService()
    {
        return $this->getServiceKernel()->createService('Kuke.BaomingService');
    }
}